<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>教育考试平台_在线考试</title>
    <link href="/css/examMain.css" rel="stylesheet" type="text/css"/>
    <link href="/css/iconfont.css" rel="stylesheet" type="text/css"/>
    <link href="/css/test.css" rel="stylesheet" type="text/css"/>

    <style>
        .hasBeenAnswer {
            background: #5d9cec;
            color: #fff;
        }

        .addButton {
            padding: 0 10px;
            cursor: pointer;
            float: right;
            height: 24px;
            line-height: 24px;
            background: #389fc3;
            color: #fff;
            border-radius: 30px;
            display: block;
            margin-top: 5px;
        }


    </style>
</head>

<body>
<div class="main">
    <!--nr start-->
    <div class="test_main">

        <div class="nr_right">
            <div class="nr_rt_main">
                <div class="rt_nr1">
                    <div class="test_content">
                        <div class="test_content_title">
                            <h2 style="padding: 0 90px;">用户基本信息</h2>
                        </div>
                    </div>
                    <div class="rt_nr1_title">
                        <h1>
                            姓名：
                        </h1>
                        <p class="test_time">
                            <input disabled="disabled" type="text" id="username"
                                   value="${sessionScope.current_user.name}" name="username"
                                   style="height: 38px;width: 122px;"/>
                        </p>
                    </div>


                    <div class="rt_nr1_title" style="margin-top: 5px;">
                        <h1>
                            学号：
                        </h1>
                        <p class="test_time">
                            <input disabled="disabled" type="text" id="stuNum"
                                   value="${sessionScope.current_user.stuNum}" name="stuNum"
                                   style="height: 38px;width: 122px;"/>
                        </p>
                    </div>
                    <div class="rt_nr1_title" style="margin-top: 5px;">
                        <h1>
                            家庭住址：
                        </h1>
                        <p class="test_time">
                            <input disabled="disabled" type="text" id="major" name="major"
                                   value="${sessionScope.current_user.homeAddress}" style="height: 38px;width: 122px;"/>

                        </p>
                    </div>

                    <div class="rt_content">
                        <div class="rt_content_tt">
                            <span>本系统会自动分发试卷进行考试</span>
                            <span onclick="checkExam()" class="addButton">开始考试</span>
                        </div>
                        <div class="rt_content_nr answerSheet">
                            <ul>

                            </ul>
                        </div>
                    </div>
                </div>

            </div>
        </div>
        <div class="nr_left">
            <div class="test">
                <form action="" method="post">
                    <div class="test_content">
                        <div class="test_content_title">
                            <h2>历史考试记录</h2>
                        </div>
                    </div>
                    <div class="test_content_nr">
                        <ul>
                            <li>
                                <div class="test_content_nr_tt">
                                    <%--<span>标题：</span>--%>
                                </div>
                                <c:forEach items="#{history}" var="history">
                                <div class="test_content_nr_main">
                                        <span>学号：${history.stuNum} / </span>
                                        <span>班级：${history.majorName} / </span>
                                        <span>姓名：${history.name} / </span>
                                        <span>分数：<fmt:formatNumber value="${history.scope}" pattern="#,##0.00#"/> / </span>
                                        <span>考试时间：
                                             <fmt:formatDate pattern="yyyy年MM月dd日" value="${history.createTime}"/>
                                        </span>
                                </div>
                                </c:forEach>
                            </li>
                        </ul>
                    </div>

                    <div class="test_content_title">
                        <div class="test_content_nr_main">

                        </div>
                    </div>

                </form>
            </div>

        </div>
    </div>
    <!--nr end-->
    <div class="foot"></div>
</div>

<script src="/js/jquery-1.11.3.min.js"></script>
<script src="/js/jquery.easy-pie-chart.js"></script>
<!--时间js-->
<script src="/js/jquery.countdown.js"></script>
<script>

    window.jQuery(function ($) {
        "use strict";

        $('time').countDown({
            with_separators: false
        });
        $('.alt-1').countDown({
            css_class: 'countdown-alt-1'
        });
        $('.alt-2').countDown({
            css_class: 'countdown-alt-2'
        });

    });

    $(function () {
        $('li.option label').click(function () {

            var examId = $(this).closest('.test_content_nr_main').closest('li').attr('id'); // 得到题目ID
            // alert(examId)
            var cardLi = $('a[href=#' + examId + ']'); // 根据题目ID找到对应答题卡
            // 设置已答题
            if (!cardLi.hasClass('hasBeenAnswer')) {
                cardLi.addClass('hasBeenAnswer');
            }

        });
    });


    function checkExam() {
        $.ajax({
            url:'/exam/checkExam',
            success:function (result) {
                if (result.code == 200) {
                    window.location.href='/exam/confirmExam';
                } else {
                    alert(result.msg);
                    return;
                }
            }
        })
    }

</script>

</body>

</html>